package com.thinqq.web.client.content.painter;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.thinqq.web.client.constants.CSSConstants;
import com.thinqq.web.client.content.EnquireThinqq;

public class EnquireThinqqContentPainer implements IContentPainter, ClickHandler, SubmitCompleteHandler{

	private FormPanel inquiryPanel=null;
	private VerticalPanel inquirethinq=null;
	@Override
	public void updateConent(HorizontalPanel mainContent, VerticalPanel relatedContent) {
		mainContent.clear();
		EnquireThinqq content = GWT.create(EnquireThinqq.class);
		
		inquirethinq = new VerticalPanel();
		inquiryPanel = new FormPanel();
		
		Label title = new Label(content.heading());
		title.setStyleName(CSSConstants.CSS_MAIN_CONTENT_TITLE);
		inquirethinq.add(title);
		Grid grid= new Grid(2,2);
		Label label = new Label(content.basicinfo()); 
			label.setStyleName("inquirytitle"); 
			grid.setWidget(0,0,label);

			//BAsic Information
			FlexTable basicpanel = new FlexTable();
			basicpanel.setCellSpacing(5);
			Label name = new Label(content.name()); 
			name.setStyleName("inquirylabel"); 
			basicpanel.setWidget(0,0,name);
			TextBox txtName = new TextBox();
			txtName.setName("name");
			basicpanel.setWidget(0,1,txtName); 
			Label organisation = new Label(content.organisation()); 
			basicpanel.setWidget(1,0,organisation);
			TextBox txtOrg = new TextBox();
			txtOrg.setName("orgname");
			basicpanel.setWidget(1,1,txtOrg); 
			Label business = new Label(content.business()); 
			basicpanel.setWidget(2,0,business);
			TextBox txtbusiness = new TextBox();
			txtbusiness.setName("business");
			basicpanel.setWidget(2,1,txtbusiness);
			Label designation = new Label(content.designation()); 
			basicpanel.setWidget(3,0,designation);
			TextBox txtdesignation = new TextBox();
			txtdesignation.setName("designation");
			basicpanel.setWidget(3,1,txtdesignation); 
			Label lookingFor = new Label(content.desired()); 
			basicpanel.setWidget(4,0,lookingFor);
			ListBox desiredService = new ListBox(true);
			desiredService.setPixelSize(200, 150);
			desiredService.addItem("Application Development", "Application Development");
			desiredService.addItem("Application Enhancement", "Application Enhancement");
			desiredService.addItem("System Re-Engineering", "System Re-Engineering");
			desiredService.addItem("Architecture Consulting", "Architecture Consulting");
			desiredService.addItem("Product planning", "Product planning");
			desiredService.addItem("Usability Engineering", "Usability Engineering");
			desiredService.addItem("Product design and development", "Product design and development");
			desiredService.addItem("Product Re-Engineering", "Product Re-Engineering");
			desiredService.setName("desiredservice");
			basicpanel.setWidget(4,1,desiredService);
			

			grid.setWidget(1,0,basicpanel);
			//ContactInformation
			Label contactlabel = new Label(content.contactinfo()); 
			contactlabel.setStyleName("inquirytitle"); 
			grid.setWidget(0,1,contactlabel);
			FlexTable contactpanel = new FlexTable();
			contactpanel.addStyleName("leftborder");
			contactpanel.setCellSpacing(5);
			Label email = new Label(content.email()); 
			contactpanel.setWidget(0,0,email);
			TextBox txtemail = new TextBox();
			txtemail.setName("email");
			contactpanel.setWidget(0,1,txtemail);
			Label businessPhone = new Label(content.businessPhone());
			contactpanel.setWidget(1,0,businessPhone);
			TextBox txtbsnsphone = new TextBox();
			txtbsnsphone.setName("businessphone");
			contactpanel.setWidget(1,1,txtbsnsphone);
			Label contactTime = new Label(content.contactTime());
			contactpanel.setWidget(2,0,contactTime);
			TextBox txtcontacttime = new TextBox();
			txtcontacttime.setName("contacttime");
			contactpanel.setWidget(2,1,txtcontacttime);
			TextArea businessAddressTA = new TextArea();
			businessAddressTA.setName("address");
			businessAddressTA.setPixelSize(200,100);
			Label businessAddress = new Label(content.businessAddress()); 
			contactpanel.setWidget(3,0,businessAddress);
			contactpanel.setWidget(3,1,businessAddressTA); 
			Label country = new Label(content.country()); 
			contactpanel.setWidget(4,0,country);
			TextBox txtcountry = new TextBox();
			txtcountry.setName("country");
			contactpanel.setWidget(4,1,txtcountry); 			
			Label zipCode = new Label(content.zipcode()); 
			contactpanel.setWidget(5,0,zipCode);
			TextBox txtZip = new TextBox();
			txtZip.setName("zip");
			contactpanel.setWidget(5,1,txtZip); 
			grid.setWidget(1,1,contactpanel);
			
			PushButton button = new PushButton("Submit");
			button.setPixelSize(80, 30);
			button.setStyleName("searchlink");
			button.addClickHandler(this);
			
			inquiryPanel.add(grid);
			inquirethinq.add(inquiryPanel);
			inquirethinq.add( new Label(content.ndaText()));
			inquirethinq.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
			inquirethinq.add(button);
			mainContent.add(inquirethinq); 
			inquiryPanel.addSubmitCompleteHandler(this);
	}

	@Override
	public void onClick(ClickEvent event) {
		inquiryPanel.setMethod(FormPanel.METHOD_POST);
		inquiryPanel.setAction("enquiry");
		inquiryPanel.submit();
	}

	@Override
	public void onSubmitComplete(SubmitCompleteEvent event) {
		inquirethinq.clear();
		Label lblThanks = new Label("Thank you for sharing the information");
		lblThanks.addStyleName("inquirylabel");
		inquirethinq.add(lblThanks);
	}
}
